package com.hk.Mgr.web.controller.order;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hk.Mgr.web.message.StatusCode;
import com.hk.base.BaseCtrl;
import com.hk.base.ResponseBase;
import com.hk.commons.vo.OrderStrMsg;
import com.hk.service.order.IOrderCheck;
import com.hk.service.order.IOrderInfo;
import com.hk.service.order.IOrderStatements;
import com.hk.service.order.IReservation;
import com.hk.service.order.impl.OrderHandleContent;
import com.hk.service.product.ICompany;
import com.hk.service.product.IProductInfo;
import com.hk.service.sys.ISysUser;

@Controller
@RequestMapping(value = BaseCtrl.MgrRootPath + "/orderCheck")
public class OrderCheckCtrl extends BaseCtrl {

	@Autowired
	private IReservation reservationService;

	@Autowired
	private ISysUser userService;

	@Autowired
	private ICompany companyService;
	
	@Autowired
	private IProductInfo productService;

	@Autowired
	private IOrderCheck orderCheckService;

	@Autowired
	private IOrderInfo orderService;

	@Autowired
	private IOrderStatements orderStatementsService;

	private Logger logger = LoggerFactory.getLogger(OrderCheckCtrl.class);

	@Autowired
	private OrderHandleContent orderContent;

	// 支付状态未确认
	public static final int HC_PAY_NO_CONFIRM = 0;

	// 支付成功
	public static final int HC_PAY_SUCC = 2;

	// 支付失败
	public static final int HC_PAY_FAIL = 1;

	/**
	 * 在火柴订单下单4个小时后检查订单的信息
	 * 
	 * @author jeff
	 * @return
	 */
	@RequestMapping(value = "/getList", method = RequestMethod.GET)
	@ResponseBody
	public ResponseBase<List<OrderStrMsg>> getList() {
		ResponseBase<List<OrderStrMsg>> resp = new ResponseBase<List<OrderStrMsg>>();
		List<OrderStrMsg> orderList = orderContent.getAllExceptionOrder();
		
		resp.setSize(orderList.size());
		resp.setResult(orderList);
		resp.setResultCode(StatusCode.SUCCESS.key());
		return resp;
	}

	/**
	 * 在火柴订单下单4个小时后检查订单的信息
	 * 
	 * @author jeff
	 * @return
	 */
	@RequestMapping(value = "/reCheck", method = RequestMethod.GET)
	@ResponseBody
	public ResponseBase<Boolean> reCheck() {
		ResponseBase<Boolean> resp = new ResponseBase<Boolean>();
		Boolean result = orderContent.reCheckHCOrder();
		resp.setResult(result);
		resp.setResultCode(StatusCode.SUCCESS.key());
		return resp;
	}

}
